package src._2;

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created by didi on 26/02/2018.
 */
public class Main {

    //按照字母序 c b a
    @Test
    void test(){
        String[] strings = {"aaa","b","cc"};
        Arrays.sort(strings, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.compareTo(o1); //逆序
            }
        });
        System.out.println(Arrays.toString(strings));
    }

    @Test
    void test2(){
        System.out.println("a".compareTo("b"));
        System.out.println("aaa".compareTo("b"));
        System.out.println("aaa".compareTo("c"));
    }

}
